package cn.inyaa.admin.sys.controller;

import cn.inyaa.admin.sys.bean.InyaaSysRole;
import cn.inyaa.admin.sys.service.InyaaSysRoleService;
import cn.inyaa.admin.sys.vo.InyaaSysRoleVo;
import com.inyaa.base.bean.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/role")
@RequiredArgsConstructor
public class InyaaSysRoleController {

    private final InyaaSysRoleService inyaaSysRoleService;

    @GetMapping("/list")
    public BaseResult<List<InyaaSysRoleVo>> list(InyaaSysRole role) {
        return BaseResult.success(inyaaSysRoleService.findRoleList(role));
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public BaseResult<String> save(@RequestBody InyaaSysRoleVo role) {
        inyaaSysRoleService.save(role);
        return BaseResult.success();
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public BaseResult<String> delete(@RequestBody InyaaSysRole role) {
        inyaaSysRoleService.delete(role);
        return BaseResult.success();
    }
}
